import service from '/@/utils/request';

export const useAccessAreaQueryApi = (code: string,) => {
    return service({
        url: `v0/access/area/query`,
        method: 'GET',
        params: { code: code },
    });
}

export const useAccessAreaPageApi = (formData?: object) => {
    return service({
        url: `v0/access/area/page`,
        method: 'POST',
        data: formData
    });
}

export const useAccessAreaCreateApi = (formData: object) => {
    return service({
        url: `v0/access/area/create`,
        method: 'POST',
        data: formData
    });
}
export const useAccessAreaUpdateApi = (formData: object) => {
    return service({
        url: `v0/access/area/update`,
        method: 'PUT',
        data: formData
    });
}

export const useAccessAreaDeleteApi = (param: string | string[]) => {
    let arrList: string[] = []

    if (param instanceof Array) {
        arrList = param
    } else {
        arrList.push(param)
    }

    return service({
        url: `v0/access/area/delete`,
        method: 'DELETE',
        data: { codeList: arrList }
    });
}

//树形结构
export const useAccessAreaChildrenApi = (code: string,) => {
    return service({
        url: `v0/access/area/children`,
        method: 'GET',
        params: { parentCode: code },
    });
}

//懒加载
export const useAccessAreaTreeApi = (code: string,) => {
    return service({
        url: `v0/access/area/tree`,
        method: 'GET',
        params: { parentCode: code },
    });
}

